﻿#include <iostream>
#include <fstream>
#include <ctime>

using namespace std; 
int numbers[5000];

void bubbleSort(int trr[])
{
    for (rsize_t i = 0; i < 4999; i++)
    {
        
        for (rsize_t j = 0; j < 4999 - i; j++)
        {
            if (trr[j] > trr[j + 1])
            {
                int a = trr[j];
                trr[j] = trr[j + 1];
                trr[j + 1] = a;
            }
        }
    }
}

void readFile(string fileName)
{
    fstream file(fileName);
    if (file.is_open())
    {
        for (size_t i = 0; i < 5000; i++)
        {
            file >> numbers[i];
        }
        clock_t start = clock();
        bubbleSort(numbers);
        clock_t end = clock();
        cout << fileName << " " << end - start << "milliseconds" << endl;
    }
    else cout << "Fail open:" << fileName << endl;
    file.close();
}

int main()
{
    readFile("m1_sorted.txt");
    readFile("m2_reverse.txt");
    readFile("m3_shuffle.txt");
}

